<?php
declare (strict_types = 1);

namespace app\validate;

use think\Validate;

class User extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'username' => 'require|mobile',
        'nickname' => 'require|max:16',
        'password' => 'require|min:8|max:16',
        'sex' => 'require|in:0,1',
        'age' => 'require|number|between:18,60',
        'tags' => 'require|array',
        'area' => 'require|array',
        'address' => 'require',
        'remark' => 'require',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'username.require' => '用户名必须',
        'username.mobile' => '用户名格式不正确',
        'nickname.require' => '昵称必须',
        'nickname.max' => '昵称长度不能超过16个字符',
        'password.require' => '密码必须',
        'password.min' => '密码长度不能小于8个字符',
        'password.max' => '密码长度不能超过16个字符',
        'sex.require' => '性别必须',
        'sex.in'=> '性别格式不正确',
        'age.require' => '年龄必须选择',
        'age.number' => '年龄格式不正确',
        'age.between' => '年龄范围不正确',
        'tags.require' => '标签必须选择',
        'tags.array' => '标签格式不正确',
        'area.require' => '地区必须选择',
        'area.array' => '地区格式不正确',
        'address.require' => '地址必须填写',
        'remark.require' => '备注必须填写',
    ];
}
